import java.util.Scanner;

public class Demo1 {//小易的升级之路

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int nums = in.nextInt();
            int star = in.nextInt();
            int[] monster = new int[nums];
            for (int i = 0 ; i < nums; i++) {
                monster[i] = in.nextInt();
            }
            for (int i = 0; i < nums; i++) {
                if (monster[i] <= star) {
                    star += monster[i];
                } else {
                    int tem = maxp(monster[i], star);
                    star += tem;
                }
            }
            System.out.println(star);
        }
    }


    static int maxp(int a, int b) {
        while (a - b != 0) {
            int c = a - b;
            if(c > b){
                a = c;
            }else {
                a = b;
                b = c;
            }
        }
        return b;
    }

}
